import request from '@/utils/request'

// 责任人

// 删除责任人信息
export function delResponsible (params) {
  var data = fromData(params)
  return request({
    url: '/responsible/del_responsible',
    method: 'post',
    data
  })
}

// 增加责任人信息
export function addResponsible (params) {
  var data = fromData(params)
  return request({
    url: '/responsible/addResponsible',
    method: 'post',
    data
  })
}

// 编辑责任人信息
export function editResponsible (params) {
  var data = fromData(params)
  return request({
    url: '/responsible/editResponsible',
    method: 'post',
    data
  })
}

// 获取责任人信息
export function getResponsibleInfo (params) {
  var data = fromData(params)
  return request({
    url: '/responsible/getResponsibleInfo',
    method: 'post',
    data
  })
}

// 获取责任人列表
export function getResponsibleArray (params) {
  var data = fromData(params)
  return request({
    url: '/responsible/getResponsibleArray',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
